| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Matrix.h
1 // Matrix.h
3 //
5
6 namespace nkMaths
7 {
13 class Matrix
14 {
15 public :
16
21 Matrix () noexcept ;
33 Matrix (float m00, float m01, float m10, float m11) noexcept ;
50 Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) noexcept ;
73 Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) noexcept ;
79 Matrix (const Matrix& other) noexcept ;
80
81 // Getters
85 Vector getRow0 () const ;
89 Vector getRow1 () const ;
93 Vector getRow2 () const ;
97 Vector getRow3 () const ;
101 Vector getCol0 () const ;
105 Vector getCol1 () const ;
109 Vector getCol2 () const ;
113 Vector getCol3 () const ;
122 float get (unsigned int row, unsigned int col) const ;
123
124 // Setters
134 Matrix& set (float val, unsigned int row, unsigned int col) ;
135
136 // Alterations
140 Matrix getInverseMat2 () const ;
144 Matrix getInverseMat3 () const ;
148 Matrix getInverseMat4 () const ;
152 Matrix getTranspose () const ;
158 Matrix& inverseMat2 () ;
164 Matrix& inverseMat3 () ;
170 Matrix& inverseMat4 () ;
176 Matrix& transpose () ;
177
178 // Transformations
184 Vector getPositionComponent () const ;
190 Matrix getOrientationComponent () const ;
196 Vector getScaleComponent () const ;
204 void getDecomposed (Vector& position, Matrix& orientation, Vector& scale) const ;
205
214 Matrix& setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
227 Matrix& setToPerspectiveMatrix (float fov, float aspect, float near, float far) ;
244 Matrix& setToOffCenterPerspectiveMatrix (float fovLeft, float fovRight, float fovTop, float fovBottom, float near, float far) ;
257 Matrix& setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float near, float far) ;
264 Matrix& setPositionComponent (const Vector& position) ;
271 Matrix& setOrientationComponent (const Quaternion& rot) ;
278 Matrix& setScaleComponent (const Vector& scale) ;
287 Matrix& setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
288
289 // Utilities
293 float getDeterminantMat2 () const ;
297 float getDeterminantMat3 () const ;
301 float getDeterminantMat4 () const ;
305 float getTraceMat2 () const ;
309 float getTraceMat3 () const ;
313 float getTraceMat4 () const ;
314
318 nkMemory::String toString () const ;
326 Matrix& fromString (nkMemory::StringView str) ;
327
328 // Operators
335 Matrix& operator= (const Matrix& other) noexcept ;
342 bool operator== (const Matrix& other) ;
349 bool operator!= (const Matrix& other) ;
356 Matrix operator+ (const Matrix& other) const ;
362 void operator+= (const Matrix& other) ;
369 Matrix operator- (const Matrix& other) const ;
375 void operator-= (const Matrix& other) ;
382 Matrix operator* (const Matrix& other) const ;
389 Vector operator* (const Vector& vec) const ;
398 Quaternion operator* (const Quaternion& q) const ;
405 Matrix operator* (float scalar) const ;
411 void operator*= (const Matrix& other) ;
417 void operator*= (float scalar) ;
424 Matrix operator/ (float scalar) const ;
430 void operator/= (float scalar) ;
431
432 public :
433
434 // Attributes
435 float _m [4][4] ;
436 } ;
437 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::fromString
Matrix & fromString(nkMemory::StringView str)
nkMaths::Matrix::toString
nkMemory::String toString() const
nkMaths::Matrix::getTraceMat2
float getTraceMat2() const
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::setOrientationComponent
Matrix & setOrientationComponent(const Quaternion &rot)
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::setScaleComponent
Matrix & setScaleComponent(const Vector &scale)
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix::_m
float _m[4][4]
The matrix memory, considered in row-major order (_m[row][col]).
Definition: Matrix.h:435
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::setToOrthographicMatrix
Matrix & setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float near, float far)
nkMaths::Matrix::setToViewMatrixDirection
Matrix & setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::setPositionComponent
Matrix & setPositionComponent(const Vector &position)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::setToOffCenterPerspectiveMatrix
Matrix & setToOffCenterPerspectiveMatrix(float fovLeft, float fovRight, float fovTop, float fovBottom, float near, float far)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Matrix &orientation, Vector &scale) const
nkMaths::Matrix::setToTransformation
Matrix & setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::Matrix
Matrix() noexcept
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::setToPerspectiveMatrix
Matrix & setToPerspectiveMatrix(float fov, float aspect, float near, float far)
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::set
Matrix & set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7